<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>demo ajax</title>
<script type="text/javascript" src="script/mootools.js"></script>
<script type="text/javascript" src="script/myscript.js"></script>
<style type="text/css">
#log{
	width: 500px;
	min-height: 100px;
	padding: 20px;
	border: 1px solid silver;
}
.sanPhamItem{
	width: 150px;
height: 150px;
border: 1px solid;
float: left;
margin-right: 10px;
padding: 10px;
}

</style>
</head>
<body>
<div id="log">

</div>

<input type="button" value="getHello" id="bt" alt="1"/>
<h1>List các button</h1>
<input class="btList" type="button" value="Nhấn" alt="1"/><br />
<input class="btList" type="button" value="Nhấn" alt="2"/><br />
<input class="btList" type="button" value="Nhấn" alt="3"/><br />

<h1>demo add cart</h1>
<div class="sanPhamItem">
	san pham A <br />
	<input type="text" size="3" value=""/><input type="button" value="add cart" alt="1"/>
</div>
<div class="sanPhamItem">
	san pham B <br />
	<input type="text" size="3" value=""/><input type="button" value="add cart" alt="2"/>
</div>
<div class="sanPhamItem">
	san pham C <br />
	<input type="text" size="3" value=""/><input type="button" value="add cart" alt="3"/>
</div>
<script type="text/javascript">
	window.addEvent('domready', function(){
			$('bt').addEvent('click', function(){
					var log=$('log');
					var idCart=$('bt').get('alt');
					var data={idSanPham: idCart};
					var url='helloAjax.html';
					var successFun= function(){ 
						alert('add cart voi san pham co id: '+idCart);
					};
					
					requestAdv(url,log,data,successFun);
				});
			$$('.btList').addEvent('click', function(e){
				var id=this.get('alt');
				alert(id);
				});

			//add su kien su ly add cart
			$$('.sanPhamItem').each(function(dom){
				var arrayDom=dom.getElements('input');
				var soLuongDom=arrayDom[0];
				var buttonDom=arrayDom[1];
				buttonDom.addEvent('click', function(){
					var idItem=this.get('alt');
					var soLuong=soLuongDom.get('value');
					alert('Add cart '+soLuong+' san pham co id '+idItem);
					});
				});
		});

</script>
</body>
</html>